'use strict';
const Service = require('egg').Service;

class UserService extends Service {
    async registry(body) {
        let res = await this.app.mysql.get("login", { email: body.email });
        // console.log(res);
        if (res) { //用户存在
            return { code: 404, msg: "该用户已注册" }
        }

        return { code: 200, msg: "注册成功", list: await this.app.mysql.insert("login", body) };
    }
    async login(body) {
        let res = await this.app.mysql.get("login", { email: body.email, password: body.password });
        console.log(res);
        if (res) {
            return { code: 200, msg: "登录成功"};
        }
        else {
            return { code: 404, msg: "登录失败" };
        }
    }
}

module.exports = UserService;
